home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C02 / GetWords.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  536 b   |  22 lines

  1. //: C02:GetWords.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Break a file into whitespace-separated words
  7. #include <string>
  8. #include <iostream>
  9. #include <fstream>
  10. #include <vector>
  11. using namespace std;
  12.  
  13. int main() {
  14.   vector<string> words;
  15.   ifstream in("GetWords.cpp");
  16.   string word;
  17.   while(in >> word)
  18.     words.push_back(word); 
  19.   for(int i = 0; i < words.size(); i++)
  20.     cout << words[i] << endl;
  21. } ///:~
  22.